#include<bits/stdc++.h>
#define int long long
#define endl "\n"
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
int a[110];

using namespace std;

signed main() {
	IOS;
	int n, ret = 0, m;
	cin >> n >> m ;
	for(int i = 1; i <= n; ++ i ) {
		cin >> a[i];
	} 
	for(int i = 1; i <= m; ++ i ) {
		int x;
		cin >> x;
		ret += a[x];
	}
	cout << ret << endl;
	return 0;
} 
